﻿using Microsoft.AspNetCore.Mvc.Filters;
using System;

namespace VisionCloud.Api.Common
{
    /// <summary>
    /// 验证模型属性
    /// </summary>
    public sealed class ValidateModelAttribute : Attribute, IActionFilter
    {
        /// <summary>
        /// anction执行后
        /// </summary>
        /// <param name="context"></param>
        public void OnActionExecuted(ActionExecutedContext context)
        {
            //context.Result = new JsonResult(new ApiResult(AjaxCode.Success, "",""));
        }

        /// <summary>
        /// action执行时
        /// </summary>
        /// <param name="context"></param>
        public void OnActionExecuting(ActionExecutingContext context)
        {
            // SystemMonitor sm = new SystemMonitor();
            // string msg = "";
            // bool bl = sm.GetPowerHealth(out msg);
            // //bl = false;
            //// msg = "4";
            // if (!bl)
            // {
            //     if (int.Parse(msg) < 9)
            //     {
            //         context.Result = new JsonResult(new ApiResult(AjaxCode.Error, "电量不足，请充电"));
            //     }
            // }
            // else
            // {
            // }
        }
    }
}